<template>
  <div style="height: 100%; overflow: hidden">
    <el-breadcrumb class="ne-padding-t-10" separator="/">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>{{secTitel}}</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="app-container m-content-box">
      <step-nav
        style="margin-bottom: 0.1rem"
        justify="center"
        :active="stepNav.active"
        :colSize="12"
        :step-data="stepNav.stepData"
      ></step-nav>
      <more-panel
        ref="morepanel"
        formRef="adodrFrom"
        :formModel="FormModel"
        :formRule="formRule"
        :boxShadow="false"
        title="订单项信息"
        clktext="详细内容"
      >
        <h1 slot="fixed">
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item label="流水号">
                <el-input
                  clearable
                  v-model="FormModel.custSoNumber"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="受理运营商" prop="orderSourceId">
                  <el-select
                    filterable
                    v-model="FormModel.orderSourceId"
                    placeholder="请选择"
                    style="width: 100%"
                    @change="slyys"
                  >
                    <el-option
                      v-for="item in operatorsList"
                      :key="item.attrValue"
                      :label="item.attrValueName + ''"
                      :value="item.attrValue + ''"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item class="clearfix" label="客户名称" required>
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.custName"
                      class="left"
                      @change="khmc"
                      :disabled="true"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item
                class="clearfix"
                label="客户联系人"
                prop="orderContactInfo[0].contactName"
              >
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.orderContactInfo[0].contactName"
                      @change="khlxr"
                      class="left"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item
                label="客户联系电话"
                prop="orderContactInfo[0].officePhone"
              >
                <el-input
                  clearable
                  v-model="FormModel.orderContactInfo[0].officePhone"
                  @change="khcontact"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item
                class="clearfix"
                label="客户地址"
                prop="orderContactInfo[0].contactAddress"
              >
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.orderContactInfo[0].contactAddress"
                      class="left"
                      @change="khaddress"
                      :disabled="contactAddressDisabled"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="客户经理" prop="custManageName">
                  <!-- <input-grid
                    v-model="FormModel.custManagerName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.custManagerId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.custManageName"
                    text="staffName"
                    @getrow="getRowCustManageHandler"
                    @loadata="loadCustManageOptions"
                    :config="custManageConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="项目经理" prop="busiManageName">
                  <!-- <input-grid
                    v-model="FormModel.busiManageName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.busiManagerId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.busiManageName"
                    text="staffName"
                    @getrow="getRowBusiManageHandler"
                    @loadata="loadBusiManageOptions"
                    :config="busiManageConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="商机" prop="saleName">
                  <!-- <input-grid
                    v-model="FormModel.saleName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.saleId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.saleName"
                    text="staffName"
                    @getrow="getRowSaleHandler"
                    @loadata="loadSaleOptions"
                    :config="saleConfig"
                    :isDisabled="custDisabled"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="合同编码" prop="contactCd">
                  <!-- <el-input
                    v-if="FormModel.extSystem == '16'"
                    v-model="FormModel.contactCd"
                  /> -->
                  <input-dialog
                    v-model="FormModel.contactCd"
                    text="contactCd"
                    @getrow="getRowContactCdHandler"
                    @loadata="loadContactCdOptions"
                    :config="contactCdConfig"
                    :isDisabled="contactCdDisabled"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="合同名称">
                <el-input
                  clearable
                  v-model="FormModel.contactName"
                  :disabled="ctNameDisable"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="MSS项目编码">
                  <input-dialog
                    v-model="FormModel.projectId"
                    text="itemcode"
                    @getrow="getRowProjectNameHandler"
                    @loadata="loadProjectNameOptions"
                    :config="projectNameConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="集团客工名称">
                  <el-input
                    v-model="FormModel.mobileName"
                    :disabled="true"
                  ></el-input>
                  <!--<input-dialog
                                  v-model="FormModel.mobileName"
                                  text="mobileName"
                                  @getrow="getRowMobileNameHandler"
                                  @loadata="loadMobileNameOptions"
                                  :config="groupNameConfig"
                          />-->
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="集团客工联系电话">
                  <el-input
                    v-model="FormModel.mobilePhone"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="集团客工邮箱">
                  <el-input
                    v-model="FormModel.mobileEmail"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="营销项目编码">
                  <input-dialog
                    v-model="FormModel.marketProjectCode"
                    text="marketProjectCode"
                    @getrow="getMarketProjectCode"
                    @loadata="loadMarketProjectOptions"
                    :config="marketProjectNameConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="营销项目名称">
                <el-input
                  clearable
                  v-model="FormModel.marketProjectName"
                  disabled
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="营销子项目编码">
                  <input-dialog
                    v-model="FormModel.marketSubprojectCode"
                    text="marketSubprojectCode"
                    @getrow="getmarketSubprojectCode"
                    @loadata="loadMarketSubprojectOptions"
                    :config="marketSubprojectNameConfig"
                    :infoTip="infoTip"
                    infoText="请先选择营销项目编码！"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="营销子项目名称">
                <el-input
                  clearable
                  v-model="FormModel.marketSubprojectName"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
        </h1>
        <!-- 可隐藏区域 -->
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item class="ne-line" label="是否跨域业务">
              <el-radio-group
                class="column-center"
                v-model="FormModel.oneSubFlag"
              >
                <el-radio size="mini" :label="1">是</el-radio>
                <el-radio size="mini" :label="2">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </el-col>
        <!-- <el-col :span="8" class="line">
          <el-form-item label="客户传真">
            <el-input clearable v-model="custModel.custMsg.contactFax" />
          </el-form-item>
        </el-col>
        <el-col :span="8" class="line">
          <el-form-item label="客户EMAIL">
            <el-input clearable v-model="custModel.custMsg.contactEmail" />
          </el-form-item>
        </el-col>
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item
              class="ne-line"
              label="是否为曲线一站服务需求"
              prop="type"
            >
              <el-radio-group
                class="column-center"
                v-model="orderModel.isCountyFlag"
              >
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </el-col> -->
        <!-- <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item label="合同编号类型">
              <el-select
                v-model="FormModel.contractNumberType"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option
                  v-for="item in contactNumTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </el-col> -->
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item label="项目名称" prop="type">
              <el-input
                v-model="FormModel.projectName"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="8" class="line">
          <el-form-item label="项目描述">
            <el-input clearable v-model="FormModel.bussDesc" />
          </el-form-item>
        </el-col>
        <el-col :span="24" class="line">
          <el-form-item label="备注">
            <el-input type="textarea" v-model="FormModel.remark"></el-input>
          </el-form-item>
        </el-col>
      </more-panel>

      <el-row>
        <el-col :span="24">
          <div class="clearfix table-title">
            <p class="tbl-title left">销售品信息</p>
            <div class="btn-grop right">
              <sales-button
                ref="salesButton"
                text="订购销售品"
                @showpop="eventShowpop"
                :dataSource="saleList"
                :topList="topList"
                :operatorsSelected="FormModel.orderSourceId"
                :custSoNumber="FormModel.custSoNumber"
                :customerOrder="backInfo"
                @click="searchSale"
              >
              </sales-button>
              <el-button type="primary" size="mini" @click="doBatchDel">
                批量删除
              </el-button>
              <el-button type="primary" size="mini" @click="doCopyOrder">
                复制
              </el-button>
              <el-button type="primary" size="mini" @click="importClick">
                导入
              </el-button>
              <el-button type="primary" size="mini" @click="qryOrderItemList"
                >导入归档单</el-button
              >
              <el-button type="primary" size="mini" @click="templateDown">
                模板下载
              </el-button>
            </div>
          </div>
        </el-col>
        <el-col :span="24">
          <div>
            <el-table
              :header-cell-style="{ background: '#F2F2F2', color: '#333' }"
              border
              @selection-change="handleSelectionChange"
              style="width: 100%"
              :data="tableData"
              v-loading="tableLoading"
              element-loading-customClass="ne-loading"
              element-loading-background="rgba(255, 255, 255, 0.6)"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column label="流水号" align="center" fixed width="180">
                <template slot-scope="scope">
                  <span>{{
                    scope.row.custSoNumber + "-" + scope.row.orderItemSeq
                  }}</span>
                </template>
              </el-table-column>
              <el-table-column
                label="销售品名称"
                prop="offerName"
                align="center"
                fixed
              >
              </el-table-column>
              <el-table-column label="要求完成时间" align="center">
                <template slot-scope="scope">
                  <span
                    v-if="
                      scope.row.reqOrderDate && scope.row.reqOrderDate != ''
                    "
                  >
                    {{ scope.row.reqOrderDate }}
                  </span>
                  <span v-else>{{ scope.row.orderDate }}</span>
                </template>
              </el-table-column>
              <el-table-column
                label="通达地点"
                prop="regionRange"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="登记事项"
                prop="serviceOfferName"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="甲端用户名称"
                prop="useCustName"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="甲端联系人"
                prop="contactName"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="甲端联系人电话"
                prop="mobilePhone"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="甲端装机地址"
                prop="addressDesc"
                align="center"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                label="乙端用户名称"
                prop="zUseCustName"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="乙端联系人"
                prop="zContactName"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="乙端联系人电话"
                prop="zMobilePhone"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="乙端装机地址"
                prop="zAddressDesc"
                align="center"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                label="速率"
                prop="rate"
                align="center"
                fixed="right"
              >
              </el-table-column>
              <el-table-column label="操作" fixed="right">
                <template slot-scope="scope">
                  <!-- 功能没做暂时去掉操作按钮 -->
                  <!-- <el-button
                    type="text"
                    size="small"
                    @click="doEdit(scope.row.id)"
                  >
                    <i class="el-icon-edit"></i>
                  </el-button> -->
                  <el-button type="text" size="small" @click="doDel(scope.row)">
                    <i class="el-icon-delete"> </i>
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-row
              type="flex"
              class="row-bg mar-15"
              justify="center"
              style="margin-bottom: 0.7rem"
            >
              <el-col :span="10">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="parseInt(pageInfo.pageIndex)"
                  background
                  :page-sizes="[5, 10, 15, 20]"
                  :page-size="pageInfo.pageSize"
                  :total="parseInt(pageInfo.rowCount)"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <div class="footBtn">
        <el-button
          type="primary"
          plain
          v-loading.fullscreen.lock="loading"
          @click="createProject(false)"
        >
          保存
        </el-button>
        <el-button
          type="primary"
          @click="doCreateAndVerify"
          plain
          v-loading.fullscreen.lock="loading"
        >
          保存并送审核</el-button
        >
      </div>
    </div>
    <fix-nav :fix-nav-list="fixNavList"></fix-nav>

    <el-dialog
      class="ne-pending-task"
      append-to-body
      :width="isContent.width"
      :top="isContent.top"
      :title="isContent.title"
      v-if="pendItemVisible"
      :visible.sync="pendItemVisible"
      :before-close="digClose"
    >
      <component
        :show.sync="pendItemVisible"
        :is="isContent.content"
        @close="fun"
        @update:show="jumpCustOrder"
        @copyArchiveClose="copyArchiveClose"
        :ODKInfo="isContent.ODKInfo"
        :CTOInfo="isContent.CTOInfo"
      ></component>
    </el-dialog>
    <!-- 导入弹窗 -->
    <el-dialog
      :close-on-click-modal="false"
      title="批量导入"
      :before-close="dialogClose"
      :visible.sync="importLoading"
      width="780px"
    >
      <div v-loading="bufferLoading" class="import-container">
        <el-form
          :model="importForm"
          :rules="importRules"
          ref="importForm"
          label-width="100px"
        >
          <el-form-item label="产品类型：" class="typeTitle" prop="waresType">
            <el-select
              clearable
              v-model="importForm.waresType"
              key-value="value"
            >
              <el-option
                v-for="item in selectList"
                :key="item.value"
                :label="item.label"
                :value="item"
              >
              </el-option>
            </el-select>
            <span class="instructions publicColor"
              >选取文件前请先选择一种产品类型！</span
            >
          </el-form-item>
          <el-form-item label="">
            <div>
              <el-upload
                class="upload-demo"
                ref="upload"
                :limit="1"
                :on-exceed="handleExceed"
                action="string"
                :on-change="changeFile"
                :on-remove="handleRemove"
                :file-list="fileList"
                :auto-upload="false"
              >
                <el-button slot="trigger" size="small" type="primary">
                  选取文件
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="submitUpload"
                  :loading="buttonLoading"
                >
                  校验上传
                </el-button>
                <div slot="tip" class="el-upload__tip">
                  （温馨提示：请选择10M以下的文件，序号字段一定要填并且是数字哦！）
                </div>
              </el-upload>
            </div>
          </el-form-item>
          <el-form-item label="导入结果提示：">
            <div class="exhibition">
              <el-input
                v-model="importForm.uploadResult"
                :disabled="true"
                type="textarea"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item label="详细信息提示：">
            <div class="exhibition">
              <el-input
                v-model="importForm.uploadClear"
                :disabled="true"
                type="textarea"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item label="批次号：">
            <div class="">
              <el-input
                :disabled="true"
                class="batchNumber"
                v-model="importForm.batchNumber"
              ></el-input>
              <el-radio-group v-model="importForm.radio">
                <el-radio :label="1" @click.native.prevent="radioClick(1)"
                  >补导入</el-radio
                >
              </el-radio-group>
              <span class="publicColor">（如为补导入请勾选此项）</span>
              <span class="lineFeed publicColor">
                （补导入是指：第一次导入校检存在错误时，修改错误后的再次导入，补导时系统将只导入修改的信息）
              </span>
            </div>
          </el-form-item>
          <div class="primaryButton">
            <el-button
              type="primary"
              @click="affirmClick"
              :disabled="isCheckedFileBtn"
              >确认</el-button
            >
            <el-button type="primary" @click="retreatClick">取消</el-button>
          </div>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import FixNav from "@/components/order/FixNav";
import MorePanel from "@/components/public/MorePanel";
import StepNav from "@/components/public/StepNav";
import OrderService from "@/api/order/OrderService.js";
import SalesButton from "@/components/custorder/SalesButton.vue";
import DeletePage from "@/components/custorder/DeletePage.vue";
import CopyOrder from "@/components/custorder/CopyOrder.vue";
import inputDialog from "@/components/public/forms/inputDialog";
import templateQuery from "@/components/order/templateQuery/index";
import SearchCondition from "@/components/order/SearchCondition/index";
import { mapMutations, mapState } from "vuex";
import SendAudit from "@/components/custorder/pengding/SendAudit";
import ElButton from "../../../node_modules/element-ui/packages/button/src/button.vue";
import { Loading } from "element-ui";
export default {
  name: "OrderAdd",
  components: {
    ElButton,
    MorePanel,
    SalesButton,
    inputDialog,
    StepNav,
    FixNav,
    DeletePage,
    CopyOrder,
    templateQuery,
    SendAudit,
    SearchCondition,
  },
  async created() {
    Object.assign(this.FormModel, {
      staffid: this.user.staffId,
      createStaff: this.user.staffId,
      orgId: this.user.orgId,
      accepteRegionId: this.user.regionId,
      accepteLanId: this.user.regionId,
    });
    // 客户信息
    // this.custModel = this.orderPosInfo.custMsg;
    // 尝试接收信息录入页面传回的路由参数
    let backInfo = this.$route.query.customerOrder;
    if (backInfo) {
      this.backInfo = backInfo;
      //受理页面返回或受理成功返回
      this.FormModel.custOrderId = backInfo.custOrderId || "";
      this.FormModel.custSoNumber = backInfo.custSoNumber || "";
      let FormModel = JSON.parse(sessionStorage.getItem("FormModel"));
      if (backInfo.custSoNumber != "" && backInfo.custSoNumber) {
        FormModel.custOrderId = backInfo.custOrderId;
        FormModel.custSoNumber = backInfo.custSoNumber;
        sessionStorage.setItem("FormModel", JSON.stringify(FormModel));
      }
    } else {
      let taskList = this.$route.query.taskList;

      if (taskList) {
        //从商机任务单页面进入
        //业务经理默认 add by cjj 20210823  商机来单业务经理取自系统，客户经理取自商机列表
        this.FormModel.busiManagerId = this.user.staffId;
        this.SET_BUSIMANAGERID(this.user.staffId);
        this.SET_XBUSIMANAGEMODEL({
          busiManagerId: this.user.staffId,
          busiManageName: this.user.staffName,
        });
        //客户经理默认
        this.FormModel.custManagerId = taskList.staffId;
        this.SET_CUSTMANAGERID(taskList.staffId);
        this.SET_XCUSTMANAGEMODEL({
          custManagerId: taskList.staffId,
          custManageName: taskList.staffName,
        });

        this.FormModel.handleStateCd = taskList.orderstage;
        this.custDisabled = true;
        taskList.orderSourceId = this.FormModel.orderSourceId;
        taskList.extSystem = "16";
        this.$store.commit("orders/SET_CUSTID", taskList.custId);
        this.$store.commit("orders/SET_CUSTNAME", taskList.custName);
        this.$store.commit("orders/SET_CUSTMSG", taskList);
        if (taskList.contractCd) {
          taskList.contactCdDisabled = true;
        } else {
          taskList.contactCdDisabled = false;
        }
        taskList.markId = "132410sj"; //增加销售品列表订购识别字段
        const ContactCdOpt = await this.getContactCdOpt({
          contractcode: taskList.contractCd,
          contractname: "",
        });
        if (ContactCdOpt) {
          taskList.signdate = ContactCdOpt.signdate || "";
          taskList.enddate = ContactCdOpt.enddate || "";
        }
        sessionStorage.setItem("FormModel", JSON.stringify(taskList));
      } else {
        //从客户定位页面进入
        //业务经理默认
        this.FormModel.busiManagerId = this.user.staffId;
        this.SET_BUSIMANAGERID(this.user.staffId);
        this.SET_XBUSIMANAGEMODEL({
          busiManagerId: this.user.staffId,
          busiManageName: this.user.staffName,
        });
        //客户经理默认
        this.FormModel.custManagerId = this.user.staffId;
        this.SET_CUSTMANAGERID(this.user.staffId);
        this.SET_XCUSTMANAGEMODEL({
          custManagerId: this.user.staffId,
          custManageName: this.user.staffName,
        });

        Object.assign(this.FormModel, this.orderPosInfo);
        //vuex里存一份
        this.SET_XCUSTMODEL(this.orderPosInfo);
        this.orderPosInfo.custMsg.orderSourceId = this.FormModel.orderSourceId;
        this.orderPosInfo.custMsg.extSystem = "10";
        this.orderPosInfo.custMsg.markId = this.elecLabel; //增加销售品列表订购识别字段
        sessionStorage.setItem(
          "FormModel",
          JSON.stringify(this.orderPosInfo.custMsg)
        );
      }
    }

    let storageFormModel = JSON.parse(sessionStorage.getItem("FormModel"));
    this.FormModel.custSoNumber = storageFormModel.custSoNumber || ""; //流水号
    this.FormModel.custOrderId = storageFormModel.custOrderId || ""; //custOrderId
    this.FormModel.contactCd = storageFormModel.contractCd || ""; //合同cd,
    this.FormModel.contactName = storageFormModel.contractName || ""; //合同名字
    this.FormModel.contactId = storageFormModel.contractId || ""; //合同id,
    this.FormModel.contractNumberType =
      storageFormModel.contractNumberType || ""; //合同编号类型,
    this.FormModel.custName = storageFormModel.custName || ""; //客户名称
    this.FormModel.custId = storageFormModel.custId || ""; //客户ID
    this.FormModel.oldPartyCode = storageFormModel.oldPartyCode || ""; //客户code
    this.FormModel.orderContactInfo[0].contactAddress =
      storageFormModel.custAddr || ""; //联系人地址
    this.contactAddressDisabled = storageFormModel.custAddr ? true : false;
    this.FormModel.orderContactInfo[0].officePhone =
      storageFormModel.contactMobilePhone || ""; //联系电话
    this.FormModel.orderContactInfo[0].contactName =
      storageFormModel.contactName || ""; //客户联系人
    this.FormModel.orderContactInfo[0].contactEmail =
      storageFormModel.contactEmail || ""; //客户联系邮箱
    this.saleName = storageFormModel.contractName || ""; //合同名称
    this.FormModel.saleId = storageFormModel.saleCd || ""; //商机
    this.FormModel.saleName = storageFormModel.saleName || ""; //商机编码
    this.FormModel.orderSourceId = storageFormModel.orderSourceId || "10000"; //受理运营商
    this.FormModel.projectId = storageFormModel.projectCode || ""; //项目ID，保存，MSS项目编码回显
    this.FormModel.projectName = storageFormModel.projectsName || ""; //项目名称
    this.FormModel.bussDesc = storageFormModel.bussDesc || ""; //项目描述
    this.FormModel.extSystem = storageFormModel.extSystem || ""; //项目描述
    this.FormModel.marketProjectCode = storageFormModel.marketProjectCode || ""; //营销项目编码
    this.FormModel.marketProjectName = storageFormModel.marketProjectName || ""; //营销项目名称
    this.FormModel.marketProjectId = storageFormModel.marketProjectId || ""; //营销项目Id
    this.FormModel.marketSubprojectCode =
      storageFormModel.marketSubprojectCode || ""; //营销子项目编码
    this.FormModel.marketSubprojectName =
      storageFormModel.marketSubprojectName || ""; //营销子项目名称
    this.FormModel.subProjectId = storageFormModel.subProjectId || ""; //营销子项目id
    // if(storageFormModel.orderstage){//商机任务单进入订单起/需求单起
    //   this.FormModel.handleStateCd = storageFormModel.orderstage || "";
    // }
    this.FormModel.applyCode = storageFormModel.applyCode || ""; //商机编码 20210812 add by cjj
    this.FormModel.applyStatus = storageFormModel.applyStatus || ""; //20210812 add by cjj
    this.FormModel.warningState = storageFormModel.warningState || ""; //20210812 add by cjj
    this.FormModel.custManagerId = storageFormModel.custManagerId || "";
    this.FormModel.signdate = storageFormModel.signdate || "";//合同生效时间 20210824 add by cjj 后面功能备用
    this.FormModel.enddate = storageFormModel.enddate || "";//合同失效时间 20210824 add by cjj 后面功能备用
    this.contactCdDisabled = storageFormModel.contactCdDisabled || false;
    if (this.FormModel.marketProjectId) {
      this.infoTip = false;
    }
    let dgSLECT = [
      { name: "PT", val: "13241001" },
      { name: "GM", val: "13241004" },
      { name: "GC", val: "13241003" },
      { name: "SJ", val: "132410sj" },
    ];

    dgSLECT.forEach((item) => {
      if (storageFormModel.markId == item.val) {
        this.markName = item.name;
      }
    });
    //商机单过来的要清楚proFlag标识
    if (this.markName == "SJ") {
      sessionStorage.removeItem("proFlag");
    }
    if (sessionStorage.getItem("proFlag") == "5G") {
      this.markName = "5G";
      this.secTitel = '5G受理'
    }
    // 销售品列表
    this.qryProdOfferList({
      catalogId: this.catalogId,
      markName: this.markName,
    });
    // 销售品列表top10
    this.getTop10({ markName: this.markName });
    // 销售品信息,下方表格数据
    if (this.FormModel.custSoNumber) {
      this.qryOrderItem();
    }
    // InputDialog控件选择的值将被vuex管理,首次加载时去读一次
    Object.assign(this.FormModel, this.xCustManageModel);
    Object.assign(this.FormModel, this.xBusiManageModel);
    //受理运营商
    let params = { attrId: "100010765", productId: "" };
    this.getAttrValueList(params);
  },
  mounted() {
    this.loadMobileNameOptions();
  },
  data() {
    return {
      tableLoading: false,
      secTitel:'业务受理',
      fixNavList: [
        {
          link: "/orderadd",
          name: "订购",
          icon: "iconfont icon-dingyue",
          active: "true",
        },
        {
          link: "",
          name: "补点",
          clickEvent: "await",
          icon: "iconfont icon-ding",
        },
        {
          link: "",
          name: "补录",
          clickEvent: "await",
          icon: "iconfont icon-lurubaogao",
        },
        {
          link: "/ordertemp",
          name: "暂存",
          icon: "iconfont icon-zancun-01",
        },
      ],
      backInfo: {}, //受理成功传回
      FormModel: {
        handleStateCd: "", //批量导入订单需求单起
        mobileName: "", //集团客工名称
        mobilePhone: "", //集团客工电话
        mobileEmail: "", //集团客工邮箱
        marketProjectCode: "", //营销项目编码
        marketProjectName: "", //营销项目名称
        marketProjectId: "", //营销项目Id
        marketSubprojectCode: "", //营销子项目编码
        marketSubprojectName: "", //营销子项目名称
        subProjectId: "", //营销子项目id
        custOrderId: "", //-----客户订单id  销售品保存页面带回建议页面增加隐藏 ✔
        custSoNumber: "", // -----流水号  销售品保存页面带回 ✔
        operType: "1000", //必传，1000新增，1200变更（单号必传），1300保持不变（单号必传，其余字段需要修改的传入）
        custOrderType: "50200001", //新装订购传 50200001
        orderSourceId: "10000", //订单受理运营商 页面取
        staffid: "", //当前登录员工id  缓存里面取 staffid（具体缓存里面存的字段名是啥还没确定）
        createStaff: "",
        orgId: "", //当前登录组织  缓存里面取 orgId
        accepteRegionId: "", // ---先空着
        accepteLanId: "", //----先空着
        custName: "", //客户名称
        custId: "", //--客户ID  客户定位页面传过来的
        oldPartyCode: "", //--客户code
        sysSource: "1000", //来源系统，固定1000
        channelId: "10", //渠道：先空 后续补充
        orderSource: "1000", //订单来源"1000"	固定1000
        bussDesc: "", //--项目描述
        remark: "", // 备注  页面取
        contactId: "", //合同id页面取
        contactCd: "", //合同页面取
        contactName: "", //--合同名称页面取
        contractNumberType: "", //合同编号类型
        projectId: "", //选择项目弹窗会带回 页面取
        projectName: "", //选择项目弹窗会带回 页面取
        projectManage: "", //--选择项目弹窗会带回
        saleId: "", // --客户定位页面带回    没有为空
        extCustOrderId: "", //--空
        custManagerId: "", //--页面客户经理 存ID 页面取
        custManageName: "", //--页面客户经理 存ID 页面取
        busiManagerId: "", //--页面业务经理 存ID 页面取
        busiManageName: "", //--页面业务经理 存ID 页面取
        isCountyFlag: "", //是否区县一站服务 页面取
        oneSubFlag: 2, //是否跨域业务  页面取
        extSystem: "", //受理渠道
        applyCode: "", //商机编码
        applyStatus: "",
        warningState: "",
        orderContactInfo: [
          {
            contactType: "1", //--客户联系人类型 默认1 TODO:需要对
            contactName: "", //--联系人名字 页面取
            homePhone: "", //--空
            officePhone: "", //--联系人邮箱 页面取
            contactEmail: "", //--客户email 页面取
            fax: "", //--客户传真 页面取
            locationId: "", //--客户定位页面带回
            contactAddress: "", // 客户地址页面取
          },
        ],
        custMsg: {},
      },
      topList: [],
      pendItemVisible: "",
      isContent: {},
      catalogId: 71, //查询销售品列表的固定值：代表订购
      loading: false,
      importLoading: false,
      custDisabled: false, //客户名称是否可修改
      ctNameDisable: false, //合同名称是否可修改
      contactAddressDisabled: true, //客户地址是否可修改
      contactCdDisabled: false, //合同编号是否可修改
      selectList: [],
      importRules: {
        waresType: [
          { required: true, message: "请先选择产品类型", trigger: "change" },
        ],
      },
      importForm: {
        waresType: null, //产品类型對象
        radio: 0, //补导入
        uploadResult: "", //结果提示
        uploadClear: "", //详细结果提示
        batchNumber: "", //第一次校验存储批次号
        batchNumTwo: "", //第二次校验存储批次号
        appendRows: "", //第一次校验存储修改行数
        appendTwo: "", //第二次校验存储修改行数
      },
      file: {},
      bufferLoading: true,
      buttonLoading: false,
      isCheckedFileBtn: true,
      fileList: [],
      multipleSelection: [],
      saleList: [],
      markName: "", //销售品列表订购传参
      // 分页模型
      pageInfo: {
        pageIndex: 1,
        pageSize: 10,
        rowCount: 0,
      },

      //FIXME: 运营商列表
      operatorsList: [],

      //FIXME: 合同编号类型列表
      contactNumTypeList: [
        { value: 1, label: "合同编号类型1" },
        { value: 2, label: "合同编号类型2" },
      ],

      formRule: {
        orderSourceId: [
          { required: true, message: "受理运营商不能为空", trigger: "change" },
        ],
        custName: [
          { required: true, message: "客户名称不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].contactName": [
          { required: true, message: "客户联系人不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].officePhone": [
          { required: true, message: "客户联系电话不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].contactAddress": [
          { required: true, message: "客户地址不能为空", trigger: "blur" },
        ],
        custManageName: [
          { required: true, message: "客户经理不能为空", trigger: "change" },
        ],
        busiManageName: [
          { required: true, message: "项目经理不能为空", trigger: "change" },
        ],
        /*projectId: [
          { required: true, message: "MSS项目编码不能为空", trigger: "change" },
        ],*/
        contactCd: [
          { required: false, message: "合同编码不能为空", trigger: "change" },
        ],
      },
      tableData: [],

      /**
       * 业务经理选项配置
       */
      busiManageConfig: {
        title: "项目经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "项目经理编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "项目经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "项目经理编码", width: "40%" },
          { field: "staffName", title: "项目经理名称", width: "40%" },
        ],
      },

      /**
       * 客户经理选项配置
       */
      custManageConfig: {
        title: "客户经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "客户经理编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "客户经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "客户经理编码", width: "40%" },
          { field: "staffName", title: "客户经理名称", width: "40%" },
        ],
      },

      /**
       * 项目经理选项配置
       */
      projectManageConfig: {
        title: "项目经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "项目经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "请输入名称" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "项目经理编码", width: "40%" },
          { field: "staffName", title: "项目经理名称", width: "40%" },
        ],
      },

      /**
       * 项目名称选项配置
       */
      projectNameConfig: {
        title: "MSS项目信息",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "itemcode",
              title: "编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "请输入名称" },
              },
            },
            {
              field: "itemname",
              title: "名称",
              itemRender: {
                name: "input",
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "itemcode", title: "项目编码", width: "40%" },
          { field: "itemname", title: "项目名称", width: "40%" },
        ],
      },
      /**
       * 集团客工选项配置
       */
      /*groupNameConfig: {
            title: "集团客工",
            tableData: [],
            tableForm: {
                items: [
                    {
                        field: "mobileName",
                        title: "客工名称",
                        itemRender: {
                            name: "input",
                            attrs: { placeholder: "请输入名称" },
                        },
                    },
                    {
                        field: "mobilePhone",
                        title: "客工电话",
                        itemRender: {
                            name: "input",
                        },
                    },
                    {
                        itemRender: {
                            name: "$button",
                            props: { content: "查询", type: "submit", status: "primary" },
                        },
                    },
                ],
                data: {}, //这个data一定要加，否则无法获取查询参数
            },
            tableColumn: [
                { field: "mobileName", title: "客工名称", width: "40%" },
                { field: "mobilePhone", title: "客工电话", width: "40%" },
            ],
      },*/
      /**
       * 商机选项配置
       */
      saleConfig: {
        title: "商机选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "商机编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "商机名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "商机编码", width: "40%" },
          { field: "staffName", title: "商机名称", width: "40%" },
        ],
      },

      /**
       * 合同编码选项配置
       */
      contactCdConfig: {
        title: "合同编码选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "contractcode",
              title: "合同编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "contractname",
              title: "合同名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {
            contractcode: "",
            contractname: "",
          }, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "contractcode", title: "合同编码", width: "40%" },
          { field: "contractname", title: "合同名称", width: "40%" },
        ],
      },
      //营销项目配置
      marketProjectNameConfig: {
        title: "营销项目选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "PMCODE",
              title: "项目编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "PMNAME",
              title: "项目名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {
            PMCODE: "",
            PMNAME: "",
          }, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "pmCode", title: "营销项目编码", width: "20%" },
          { field: "pmName", title: "营销项目名称", width: "20%" },
          { field: "pmId", title: "营销项目ID", width: "20%" },
          { field: "pmCustManager", title: "客户经理名称", width: "20%" },
          { field: "pmManager", title: "项目经理名称", width: "20%" },
        ],
      },
      //营销子项目配置
      marketSubprojectNameConfig: {
        title: "营销子项目选项",
        tableData: [],
        tableForm: {},
        tableColumn: [
          { field: "initProductCode", title: "营销项目编码", width: "20%" },
          { field: "productName", title: "营销项目名称", width: "20%" },
        ],
      },
      /**
       * 送审核参数收集
       */
      verifyModel: null,
      infoTip: true, //营销子项目编码是否可选
    };
  },
  computed: {
    ...mapState("orders", ["elecLabel", "orderPosInfo","respCustId"]),
    ...mapState("user", ["user"]),
    ...mapState("orders", ["stepNav"]),
    ...mapState("orderAdd", ["xCustManageModel", "xBusiManageModel"]),
  },

  methods: {
    ...mapMutations("user", ["SET_BUSIMANAGERID", "SET_CUSTMANAGERID"]),
    ...mapMutations("orders", [
      "SET_DEALTYPE",
      "SET_QRYTYPE",
      "SET_QRYVALUE",
      "SET_ORDERSTAGEID",
    ]),
    ...mapMutations("orderAdd", [
      "CLEAR_XMODEL",
      "SET_XCUSTMODEL",
      "SET_XCUSTMANAGEMODEL",
      "SET_XBUSIMANAGEMODEL",
      "SET_XPROJECTMODEL",
      "SET_XCONTACTMODEL",
      "SET_XSALEMODEL",
      "SET_XORDERMODEL",
    ]),
    detailedEntrance() {
      const ppmCondition = {
        productId: "80008007",
        serviceOfferId: "4010100000",
        modType: "50030002",
        optionId: "310",
      };
      sessionStorage.setItem("ppmCondition", JSON.stringify(ppmCondition));
      this.$router.push({ name: `productinfo` });
    },
    fun() {
      this.pendItemVisible = false;
      this.qryOrderItem();
    },
    //审核弹窗关闭后跳转到销售页面
    jumpCustOrder() {
      if (this.isContent.content == "SendAudit") {
        if (sessionStorage.getItem("proFlag")) {
          this.$router.push({
            path: `/custinfo`,
            query: { proFlag: sessionStorage.getItem("proFlag") },
          }); //5G产品要带标识跳转
        } else {
          this.$router.push({ name: `custinfo` });
        }
      }
    },
    //审核弹窗关闭后跳转到销售页面
    digClose() {
      if (this.isContent.content == "SendAudit") {
        if (sessionStorage.getItem("proFlag")) {
          this.$router.push({
            path: `/custinfo`,
            query: { proFlag: sessionStorage.getItem("proFlag") },
          }); //5G产品要带标识跳转
        } else {
          this.$router.push({ name: `custinfo` });
        }
      }
      this.pendItemVisible = false;
    },
    //设置缓存
    setStorageItem(item, value) {
      let FormModel = JSON.parse(sessionStorage.getItem("FormModel"));
      FormModel[item] = value;
      sessionStorage.setItem("FormModel", JSON.stringify(FormModel));
    },
    //受理运营商
    async getAttrValueList(params) {
      //获取页面下拉框值
      let loadingInstance = Loading.service({ fullscreen: true });
      const result = await OrderService.getAttrValueList(params);
      loadingInstance.close();
      if (result.code == 200) {
        let attrValueList = result.meta.attrValueList;
        this.operatorsList = [...attrValueList];
      }
    },
    slyys() {
      //受理运营商点击事件
      this.setStorageItem("orderSourceId", this.FormModel.orderSourceId);
    },
    khmc() {
      //客户名称
      this.setStorageItem("custName", this.FormModel.custName);
    },
    khlxr() {
      //客户联系人
      this.setStorageItem(
        "contactName",
        this.FormModel.orderContactInfo[0].contactName
      );
    },
    khcontact() {
      //客户联系电话
      this.setStorageItem(
        "contactMobilePhone",
        this.FormModel.orderContactInfo[0].officePhone
      );
    },
    khaddress() {
      //客户联系地址
      this.setStorageItem(
        "custAddr",
        this.FormModel.orderContactInfo[0].contactAddress
      );
    },
    /**
     * 1加载业务经理配置选项
     */
    async loadBusiManageOptions(params) {
      const data = {
        orgId: this.user.orgId, //session里取
        postCode: "016_XMJLYWJL", //客户经理  014_KHJL    业务经理  016_XMJLYWJL
        pageSize: "20",
        pageIndex: "1",
        ...params,
      };
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.busiManageConfig.tableData = res.meta.staffIdList || [];
      }
    },

    /**
     * 2加载客户经理配置选项
     */
    async loadCustManageOptions(params) {
      const data = {
        orgId: this.user.orgId, //session里取
        postCode: "014_KHJL", //客户经理  014_KHJL    业务经理  016_XMJLYWJL
        pageSize: "20",
        pageIndex: "1",
        ...params,
      };
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.custManageConfig.tableData = res.meta.staffIdList || [];
      }
    },

    /**
     * 3加载项目经理配置选项
     */
    async loadProjectManageOptions(data) {
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        // this.projectManageConfig.tableData = res.meta.resultObject.staffIdList || [];
        this.projectManageConfig.tableData = res.meta.staffIdList || [];
      }
    },

    /**
     * 4加载项目名称配置选项
     */
    async loadProjectNameOptions(data) {
      const params = {
        requestObject: {
          projectJson: {
            itemcode: data.itemcode || "",
            itemname: data.itemname || "",
            page: {
              pageNo: 1,
              pageSize: 10,
            },
          },
        },
      };
      let res = await OrderService.qryProjectList(params);
      /*res = {code: 200,meta: { returnJson: [
            {itemcode: "XYJACQZHX180801503",itemname: "无合同立项",itemdesc: "",applydate: "2017-01-01 00:00:00.0", },
       ],}, };*/
      if (res.code == 200) {
        this.projectNameConfig.tableData = res.meta || [];
      }
    },
    /**
     * 5加载商机配置选项
     */
    async loadSaleOptions(data) {
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.saleConfig.tableData = res.meta.resultObject
          ? res.meta.resultObject.staffIdList
          : [];
      }
    },

    /**
     * 6加载合同编码配置选项
     */
    async loadContactCdOptions(params) {
      let booleanType = 0;
      if ("contractcode" in params || "contractname" in params) {
        booleanType =
          params.contractcode !== "" || params.contractname !== "" ? 1 : 0;
      }
      let obj = {
        requestObject: {
          contractJson: {
            contractcode: "contractcode" in params ? params.contractcode : "",
            contractname: "contractname" in params ? params.contractname : "",
            itemcode: "",
            itemname: "",
            type: booleanType,
            page: {
              pageNo: 1,
              pageSize: 10,
            },
          },
        },
      };
      let res = await OrderService.qryContractList(obj);

      if (res.code == 200) {
        this.contactCdConfig.tableData = res.meta || [];
      }
    },
    /**
     * 7.加载营销项目编码配置选项
     */
    async loadMarketProjectOptions(params) {
      let obj = {
        PMCUSTNUMBER: this.FormModel.oldPartyCode, // 客户编码 oldPartyCode
        PMCUST: this.FormModel.custName, //客户名称
        PMCUSTMANAGERID: this.FormModel.custManagerId, //客户经理id  没填可以是空
        PMCUSTMANAGER: this.FormModel.custManageName, //客户经理名称  没填可以是空
        PMMANAGERID: this.FormModel.busiManagerId, //项目户经理id   没填可以是空
        PMMANAGER: this.FormModel.busiManageName, //项目经理名称   没填可以是空
        CONTRACTCODE: this.FormModel.contactCd, //合同编码  没填可以是空
        CONTRACTNAME: this.FormModel.contactName, //合同名称  没填可以是空
        PMCODE: "PMCODE" in params ? params.PMCODE : "", //项目编码   没填可以是空
        PMNAME: "PMNAME" in params ? params.PMNAME : "", //项目名称  没填可以是空
        pageIndex: "1",
        pageSize: "10",
      };
      let res = await OrderService.getMarProInfo(obj);
      if (res.code == 200) {
        this.marketProjectNameConfig.tableData = res.meta.returnjson || [];
      }
    },
    /**
     * 8.加载营销子项目编码配置选项
     */
    async loadMarketSubprojectOptions() {
      let obj = {
        pmId: this.FormModel.marketProjectId,
        pageIndex: "1",
        pageSize: "10",
      };
      let res = await OrderService.getMarSubProInfo(obj);
      if (res.code == 200) {
        this.marketSubprojectNameConfig.tableData = res.meta.returnjson || [];
      }
    },

    /**
     * 1业务经理回传ID
     *
     */
    getRowBusiManageHandler(row) {
      // this.busiManageModel.busiManagerId = row.staffId;
      this.FormModel.busiManagerId = row.staffId;
      this.SET_BUSIMANAGERID(row.staffId);
      this.SET_XBUSIMANAGEMODEL({
        busiManagerId: row.staffId,
        busiManageName: row.staffName,
      });
    },
    /**
     * 2客户经理回传ID
     */
    getRowCustManageHandler(row) {
      // this.custManageModel.custManagerId = row.staffId;
      this.FormModel.custManagerId = row.staffId;
      this.SET_CUSTMANAGERID(row.staffId);
      this.SET_XCUSTMANAGEMODEL({
        custManagerId: row.staffId,
        custManageName: row.staffName,
      });
    },

    /**
     * 3项目经理回传ID
     */
    getRowProjectManageHandler(row) {
      // this.projectModel.projectManage = row.id;
      this.FormModel.projectManage = row.id;
    },

    /**
     * 4项目名称回传ID
     */
    getRowProjectNameHandler(row) {
      this.FormModel.projectId = row.itemcode;
      this.FormModel.projectName = row.itemname;
      this.FormModel.bussDesc = row.itemdesc;
      this.setStorageItem("projectCode", row.itemcode); //项目ID
      this.setStorageItem("projectsName", row.itemname); //项目名称
      this.setStorageItem("bussDesc", row.itemdesc); //项目描述
    },

    /**
     * 5商机回传ID
     */
    getRowSaleHandler(row) {
      // this.saleModel.saleId = row.id;
      this.FormModel.saleId = row.id;
    },

    /**
     * 6合同编码回传ID
     */
    getRowContactCdHandler(row) {
      // this.contactModel.contactId = row.id;
      this.FormModel.contactName = row.contractname;
      this.FormModel.contactCd = row.contractcode;
      this.FormModel.contractNumberType = row.contracttype;
      this.ctNameDisable = true;
      this.setStorageItem("contractCd", row.contractcode); //合同编码
      this.setStorageItem("contractName", row.contractname); //合同名称
      this.setStorageItem("contractId", row.contractid); //合同ID
      this.setStorageItem("contractNumberType", row.contracttype); //合同编号类型
      this.setStorageItem("signdate", row.signdate); //合同生效时间
      this.setStorageItem("enddate", row.enddate); //合同生效时间
    },
    /**
     * 7.营销项目编码回传ID
     */
    getMarketProjectCode(row) {
      this.FormModel.marketProjectCode = row.pmCode;
      this.FormModel.marketProjectName = row.pmName;
      this.FormModel.marketProjectId = row.pmId;
      this.setStorageItem("marketProjectCode", row.pmCode); //营销项目编码
      this.setStorageItem("marketProjectName", row.pmName); //营销项目名称
      this.setStorageItem("marketProjectId", row.pmId); //营销项目名称
      this.infoTip = false;
    },
    /**
     * 8.营销子项目编码回传ID
     */
    getmarketSubprojectCode(row) {
      this.FormModel.marketSubprojectCode = row.initProductCode;
      this.FormModel.marketSubprojectName = row.productName;
      this.FormModel.subProjectId = row.initProductId;
      this.setStorageItem("marketSubprojectCode", row.initProductCode); //营销子项目编码
      this.setStorageItem("marketSubprojectName", row.productName); //营销子项目名称
      this.setStorageItem("subProjectId", row.initProductId); //营销子项目名称
    },
    /**
     * 销售品信息查询
     */
    async qryOrderItem() {
      this.tableLoading = true;
      const result = await OrderService.qryOrderItem({
        // custOrderId: this.orderModel.custOrderId,
        custOrderId: this.FormModel.custOrderId,
        // custSoNumber: this.orderModel.custSoNumber,
        custSoNumber: this.FormModel.custSoNumber,
        statusCds: "101398", //在新建订单时，这个值时写死的：110095
        staffid: this.user.staffId, //从用户session中获取，员工号
        orgId: this.user.orgId, //从session中取
        custId: this.FormModel.custId || "",
        pageInfo: {
          pageIndex: this.pageInfo.pageIndex || 1,
          pageSize: this.pageInfo.pageSize || 10,
        },
      });
      this.tableLoading = false;
      if (result.code == 200) {
        this.tableData = result.meta.offerOrderItems;
        this.pageInfo.pageSize = result.meta.pageInfo.pageSize;
        this.pageInfo.pageIndex = result.meta.pageInfo.pageIndex;
        this.pageInfo.rowCount = result.meta.pageInfo.rowCount;
        //销售品信息查询成功后添加合同编码必填验证
        if (this.tableData.length >= 1) {
          let FormModel = JSON.parse(sessionStorage.getItem("FormModel"));
          if (FormModel.orderstage && FormModel.orderstage == 50030003) {
            this.formRule.contactCd[0].required = true;
          }
        }
      }
    },

    /**
     * 销售品列表查询
     */
    async qryProdOfferList(condition) {
      const result = await OrderService.qryProdOfferList(condition);
      if (result.code == 200) {
        this.saleList = result.meta.resultObject || [];
      }
    },

    /**
     * 销售品列表TOP10
     */
    async getTop10(params) {
      let result = await OrderService.getTop10(params);
      if (result.code == 200) {
        this.topList = result.meta;
      }
    },

    /**
     * 校验订单项信息
     */
    validOrderItems() {
      let result = false;
      let adodrFrom = this.$refs.morepanel.$refs.adodrFrom;
      adodrFrom.validate((valid) => {
        result = valid;
      });
      return result;
    },
    /**
     * 单独针对订购销售品按钮的校验
     */
    validSalesButton() {
      let adodrFrom = this.$refs.morepanel.$refs.adodrFrom;
      adodrFrom.validate(async (valid) => {
        if (!valid) {
          setTimeout(() => {
            this.$refs.salesButton.$refs.popper.showPopper = false;
          });
        }
      });
    },

    /**
     * 销售品列表搜索框查询
     */
    async searchSale(value) {
      this.qryProdOfferList({
        catalogId: this.catalogId,
        offerName: value,
        markName: this.markName,
      });
    },

    /**
		 * 保存新订单
		 * {
				"customerOrder": {
					"custSoNumber": "JT202100007287",
					"custId": "151",
					"custOrderId": "11193",
					"mainOrderItems": "12167"

          tacheId
          taskId
          activityId
          processInstId
          batch_nbr

				},
				"resultCode": "0"
			}
		 */

    async createProject(beforeVerify) {
      //如果保存成功，返回0
      let rtnCode = 1;
      const valid = this.validOrderItems();
      if (!valid) return;
      if (this.FormModel.custOrderId == "") {
        this.$confirm("必须要订购销售品才能保存！", "提示", {
          confirmButtonText: "确定",
          showCancelButton: false,
          type: "warning",
          center: true,
        });
        return rtnCode;
      }
      if (this.FormModel.custOrderId != "" && this.tableData.length <= 0) {
        this.$confirm("销售品列表为空，无法保存", "提示", {
          confirmButtonText: "确定",
          showCancelButton: false,
          type: "warning",
          center: true,
        });
        return;
      }
      //项目保存规则埋点
      var ruleParam = [
        {
          PUB_REQ: {
            TYPE: "GOVCRM.ORDERSET.OrdSave",
          },
          ORD_SAVE: {
            CUST_ID: this.FormModel.custId,
            SERVICE_OFFER_ID: "4010100000", //业务编码
            APPLY_INFO: this.FormModel.saleId + "", //商机编码
            ORD_LEN: this.tableData.length + "", // 所选订单数量
            CUST_SO_NUMBER: this.FormModel.custSoNumber + "", //流水号
            SOURCE_ID: this.FormModel.orderSourceId + "", // 受理运营商ID
            CONTACT_CD: this.FormModel.contactCd + "", // 合同号
            EMAIL: this.FormModel.orderContactInfo[0].contactEmail || "", // 邮箱 传值参照 create Project.js 1223行的 $("#CONTACT-E_MAIL").val()
            // "IS_BIND_WGZJ": "1", //是否捆绑受理网管专家 传值参照 create Project.js 1391行的 $("#ORDER-IS_BIND_WGZJ").val()
            // "LAIHAN_FLAG": "1", //客户来函属性 传值参照 create Project.js 1488行的 $('#ORDER-IS_LAIHAN_FLAG').val()
            OFFER_ID: "", //销售品ID  单个值
          },
          ORD_SAVE_PROD: {
            CUST_ID: this.FormModel.custId,
            SERVICE_OFFER_ID: "4010100000", //业务编码
            OFFER_ID:
              this.tableData.length > 0 ? this.tableData[0].offerId + "" : "", //销售品ID  单个值
            PROJECT_CODE:
              this.tableData.length > 0 ? this.FormModel.projectId + "" : "", //项目编码
            PROD_INST_ID:
              this.tableData.length > 0
                ? this.tableData[0].prodInstId + ""
                : "", //   传值参照 create Project.js 1505行的 $("#procProdInstId").val();
            ORD_PROD_INST_ID:
              this.tableData.length > 0
                ? this.tableData[0].ordProdInstId + ""
                : "", //   传值参照 create Project.js 1506行的 $("#groupProdInstId").val();
            CUST_SO_NUMBER: this.FormModel.custSoNumber + "", //流水号
            CONTACT_ID: this.FormModel.contactCd + "", //合同编码
          },
        },
      ];
      //调用规则平台
      let ruleCode = await this.callRule(ruleParam);

      if (ruleCode == 2) {
        //如果返回2校验不通过
        return rtnCode;
      }

      //----原逻辑-----
      // this.loading = true;
      // let result = await OrderService.createProject(this.requestObject);
      let result = await OrderService.createProject(this.FormModel);
      if (result.code == 200) {
        this.loading = false;
        if (result.meta.resultCode == 0) {
          //准备返回成功code
          rtnCode = 0;
          const customerOrder = result.meta.resultObject.customerOrder;
          //保存成功记得CLEAR_XMODEL清除vuex中的状态值,保证创建其它订单时不被脏读
          this.CLEAR_XMODEL();
          // 跳转工单信息时,初始化该页面状态
          this.SET_DEALTYPE("DEAL");
          this.SET_QRYTYPE(1);
          this.SET_QRYVALUE(customerOrder.custSoNumber);
          this.SET_ORDERSTAGEID("");
          this.verifyModel = customerOrder;
          if (!beforeVerify) {
            sessionStorage.removeItem("FormModel"); //移除项目新建缓存
            this.$message({
              type: "success",
              message: "保存成功!",
            });
            this.$router.push({
              name: `custorder`,
              params: {
                customerOrder: result.meta.resultObject.customerOrder,
              },
            });
          }
        } else {
          this.$message({
            type: "error",
            message: "保存失败!" + result.meta.resultMsg,
          });
        }
      } else {
        this.loading = false;
        await this.$message({
          showClose: true,
          message: "保存失败",
          type: "error",
        });
      }
      // -----原逻辑------
      return rtnCode;
    },

    handleSizeChange(size) {
      this.pageInfo.pageSize = size;
      this.qryOrderItem();
    },

    handleCurrentChange(pageIndex) {
      this.pageInfo.pageIndex = pageIndex;
      this.qryOrderItem();
    },

    /**
     * 表格多选事件函数
     */
    handleSelectionChange(sel) {
      this.multipleSelection = sel;
    },

    /**
     * 单条删除
     */
    doDel(row) {
      var orderItemIds = row.orderItemId;
      var reqMap = {
        orderItemIds: orderItemIds,
        custSoNumber: row.custSoNumber,
        staffId: this.user.staffId + "",
        custId: row.custId,
      };

      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.content = "DeletePage";
      this.pendItemVisible = true;
    },
    /**
     * 模板导出
     */
    templateDown(row) {
      this.isContent.ODKInfo = {};
      // this.isContent.ODKInfo.reqMap = reqMap;
      // this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.width = "1000px";
      this.isContent.content = "templateQuery";
      this.pendItemVisible = true;
    },
    /**
     * 单条编辑
     */
    doEdit(row) {},
    /**
     * 批量删除
     */
    doBatchDel() {
      if (this.multipleSelection.length == 0) {
        this.$message({
          type: "warn",
          message: "至少选择一条订单!",
        });
        return;
      }

      var orderItemIds = "";
      for (var i = 0; i < this.multipleSelection.length; i++) {
        if (i == 0) {
          orderItemIds += this.multipleSelection[i].orderItemId;
        } else {
          orderItemIds += "," + this.multipleSelection[i].orderItemId;
        }
      }

      var reqMap = {
        orderItemIds: orderItemIds,
        custSoNumber: this.multipleSelection[0].custSoNumber,
        staffId: this.user.staffId + "",
        custId: this.multipleSelection[0].custId,
      };

      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.content = "DeletePage";
      this.pendItemVisible = true;
    },
    async doCopyOrder() {
     if(sessionStorage.getItem('proFlag') == '5G'){
          this.$message({
             type: "warn",
             message: "行业5G消息产品不能操作复制功能!",
          });
          return;
      }  
      if (this.multipleSelection.length == 0) {
        this.$message({
          type: "warn",
          message: "必须选中一条记录然后再复制！",
        });
        return;
      }
      
      var reqMap = {
        orderItemId: this.multipleSelection[0].orderItemId,
        custSoNumber: this.multipleSelection[0].custSoNumber,
        custOrderId: this.multipleSelection[0].custOrderId,
        custId: this.multipleSelection[0].custId,
      };
      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.content = "CopyOrder"; //对应的Vue
      this.pendItemVisible = true; //弹框显示
    },
    eventShowpop() {
      this.validSalesButton();
    },

    //调用规则平台通用方法 lb
    async callRule(ruleParam) {
      this.loading = true;
      const result = await OrderService.rulePlatfromCheck(ruleParam);
      let ruleCode = result.code;
      let ruleMsg = result.msg;
      //直接通过校验
      if (ruleCode != 0) {
        this.loading = false;
        //校验结果有警告或者拒绝，弹窗提示
        //图标样式
        let iconType = "warning";
        if (ruleCode == 2) {
          iconType = "error";
        }
        await this.$confirm(ruleMsg, "提示", {
          confirmButtonText: "确定",
          type: iconType,
        })
          .then(() => {})
          .catch(() => {});
      }
      return ruleCode;
    },

    //保存送审核
    async doCreateAndVerify() {
    if(sessionStorage.getItem('proFlag') == '5G'){
          this.$message({
             type: "error",
             message: "行业5G消息产品不能操作保存送审核!",
          });
          return;
    }      
      const valid = this.validOrderItems();
      if (!valid) return;
      // const loading = this.$loading({
      //   lock: true,
      //   text: "正在进入项目保存和送审核流程.....",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.5)",
      // });
      // 1.先进行项目保存
      let createSaveRtnCode = await this.createProject(true);

      //保存失败直接返回
      if (createSaveRtnCode == 1) {
        return;
      }

      /**
		 * 保存新订单返回
     {
			"customerOrder": {
				"orderAuditIds": "14704",
				"custSoNumber": "JT202100010378",
				"custId": "50",
				"custOrderId": "37510",
				"mainOrderItemIds": ["95327"],
				"activityId": "TACHE00020001:2ba5f2e0-eab8-11eb-a961-525400bb686d",
				"batchNbr": 0,
				"tacheId": "TACHE0000",
				"processInstId": "2ba50869-eab8-11eb-a961-525400bb686d",
				"orderAuditId": "14704",
				"taskId": "TACHE00020001"
			}
		 */
      //送审核规则埋点（待处理工单规则埋点）
      var ruleParam = [
        {
          PUB_REQ: {
            TYPE: "GOVCRM.TASK.taskLevel",
          },

          ORDER_AUDIT_CHECK: {
            TASK_ID: this.verifyModel.taskId + "",
            CUST_SO_NUMBER: this.verifyModel.custSoNumber + "",
            BATCH_NO: this.verifyModel.batchNbr + "",
            CUST_ORDER_TYPE: this.FormModel.custOrderType + "",
            TASK_ID2: this.verifyModel.taskId + "",
            CUST_ID: this.verifyModel.custId + "",
            PRODUCT_ID: this.tableData[0].prodId + "",
          },
        },
      ];
      //调用规则平台
      let ruleCode = await this.callRule(ruleParam);
      this.loading = false;

      if (ruleCode == 2) {
        //如果返回2不打开送审核页面，直接跳转到待处理页面，否则打开送审核页面

        return;
      }
      if (this.verifyModel) {
        this.isContent.ODKInfo = { ...this.verifyModel };
        this.isContent.CTOInfo = { ...this.verifyModel };
        // this.isContent.CTOInfo.custId = this.custModel.custMsg.custId;
        this.isContent.CTOInfo.custId = this.FormModel.custId;
        this.isContent.CTOInfo.cb = () => {
          sessionStorage.removeItem("FormModel"); //移除项目新建缓存
          this.$message({
            type: "success",
            message: "保存成功!",
          });
          this.$router.push({
            name: `custorder`,
            params: {
              customerOrder: this.verifyModel,
            },
          });
        };
        this.isContent.width = "800px";
        this.isContent.content = "SendAudit";
        //3.进入送审核流程
        this.pendItemVisible = true;
      }
      // loading.close();
    },
    /**
     * 导入弹窗
     */
    importClick() {
      const valid = this.validOrderItems();
      if (!valid) return;
      let params = {
        interFaceType: "ORDER",
        sqlId: "2021062801",
        paramStr: "1",
      };
      this.getProductType(params);
      this.importLoading = true;
    },
    async getProductType(params) {
      const result = await OrderService.executeSql(params);
      if (result.code == 200) {
        this.bufferLoading = false;
        let productData = result.meta.resList.executeSqlResps;
        for (let i = 0; i < productData.length; i++) {
          productData[i].label = productData[i].templateName;
          productData[i].value = productData[i].templetId;
          this.selectList.push(productData[i]);
        }
      } else {
        this.bufferLoading = false;
      }
    },
    //弹窗关闭
    dialogClose() {
      this.$refs.importForm.resetFields();
      this.importLoading = false;
      this.importForm.waresType = null;
      this.selectList = [];
      this.file = {};
      this.importForm.uploadResult = "";
      this.importForm.uploadClear = "";
      this.importForm.batchNumber = "";
      this.importForm.appendRows = "";
      this.importForm.radio = 0;
      this.isCheckedFileBtn = true;
      this.$refs.upload.clearFiles();
      this.buttonLoading = false;
    },
    //确认按钮
    affirmClick() {
      if (this.importForm.batchNumber != "") {
        let params = {
          batchTaskId: this.importForm.batchNumber,
        };
        this.uplConfirmFile(params);
      } else if (this.importForm.batchNumber == "") {
        this.$message({
          message: this.importForm.uploadClear,
          type: "warning",
          showClose: true,
        });
      }
    },
    //取消按钮
    retreatClick() {
      this.dialogClose();
    },
    //只允许上传一个文件事件
    handleExceed() {
      this.$message({
        message: "只允许上传一个文件",
        type: "warning",
        showClose: true,
      });
    },
    async uplConfirmFile(params) {
      const result = await OrderService.saveImportFile(params);
      if (result.code == 200) {
        if (result.meta.resultCode == 0) {
          this.$message({
            message: "导入成功",
            type: "success",
            showClose: true,
          });
          this.FormModel.custOrderId =
            result.meta.resultObject.orders[0].custOrderId; //销售品信息列表擦查询条件赋值
          this.FormModel.custSoNumber =
            result.meta.resultObject.orders[0].custSoNumber; //销售品信息列表擦查询条件赋值
          this.qryOrderItem(); //更新销售品信息列表
          this.dialogClose();
        } else if (result.meta.resultCode == 1) {
          this.$message({
            message: result.meta.resultMsg,
            type: "warning",
            showClose: true,
          });
          this.dialogClose();
        } else {
          this.$message({
            message: "导入异常",
            type: "warning",
            showClose: true,
          });
          this.dialogClose();
        }
      } else {
        this.$message({
          message: result.data,
          type: "warning",
          showClose: true,
        });
      }
    },
    //校验上传按钮
    submitUpload() {
      //在第二次校验上传之前就要点击补导入，才会起作用。
      this.$refs.importForm.validate((valid) => {
        if (valid) {
          if (this.file.size > 1) {
            let uploadData = new FormData();
            uploadData.append("file", this.file); //文件
            uploadData.append("templetId", this.importForm.waresType.templetId || "");
            uploadData.append("prodId", this.importForm.waresType.prodId || "");
            uploadData.append("offerId", this.importForm.waresType.offerId || "");
            uploadData.append("custId", this.FormModel.custId || "");
            uploadData.append("respCustId", this.respCustId || "");
            uploadData.append("custName", this.FormModel.custName || "");
            uploadData.append("custOrderId", this.FormModel.custOrderId || "");
            uploadData.append("staffId", this.user.staffId || "");
            uploadData.append("orgId", this.user.orgId || "");
            uploadData.append("regionId", this.user.regionId);
            uploadData.append("dealType", "1");
            uploadData.append("jtFlag", this.importForm.waresType.jtFlag || "");
            uploadData.append("creatType", this.importForm.waresType.creatType || "");
            uploadData.append("handleStateCd", this.FormModel.handleStateCd || "");
            if (this.importForm.radio === 0) {
              //用户没点击到补导入按钮
              this.uplCheckFile(uploadData);
              this.buttonLoading = true;
            } else if (
              this.importForm.radio === 1 &&
              this.importForm.appendTwo != "" &&
              this.importForm.batchNumTwo != ""
            ) {
              //用户点击到补导入按钮 且 appendTwo和batchNumTwo不能为空
              uploadData.append("appendRows", this.importForm.appendTwo);
              uploadData.append("batchTaskId", this.importForm.batchNumTwo);
              this.uplCheckFile(uploadData);
              this.buttonLoading = true;
            } else {
              //还没有进行过校验时，防止用户误操作点击到补导入按钮
              this.uplCheckFile(uploadData);
              this.buttonLoading = true;
            }
          } else if (this.file.size === undefined) {
            this.$message({
              message: "请选取文件",
              type: "warning",
              showClose: true,
            });
          }
        } else {
          return false;
        }
      });
    },
    async uplCheckFile(params) {
      /* result.meta.resultCode=0的时候我就返回batchTaskId;
             result.meta.resultCode=1的时候我会返回appendRows跟batchTaskId; 你要补导的时候你也需要把这两个字再给我
             result.meta.resultCode=2的时候我就返回就报错不存数据,需要重新填写模板数据导入
         补导入：用户更正excel后，第二遍校验上传的时候，由于excel 100%正确，上次appendRows跟batchTaskId并未被清除，
             所以用户可以选择补导入上传，也可不选（使文件作为一个全新而且100%正确的excel直接上传到后台），
         */
      const result = await OrderService.checkImportFile(params);
      if (result.code == 200) {
        this.buttonLoading = false; 
        if (result.meta.resultCode == 0) {
          //完全正确，直接点击确认按钮导入成功。
          this.importForm.uploadResult = result.msg + ",文件输入正确";
          this.importForm.batchNumber = result.meta.resultObject.batchTaskId;
          this.importForm.uploadClear = result.meta.resultMsg;
          this.isCheckedFileBtn = false;
          this.buttonLoading = false;
        } else if (result.meta.resultCode == 1) {
          //部分错误的时候，
          //第一次会存储下来batchNumTwo、appendTwo，第二次如果excel正确了，走的上面的resultCode==0 逻辑
          //第二次如果excel错误了，还走resultCode == 1 这里，继续赋值batchNumTwo、appendTwo（中台要的始终是最新的）
          this.importForm.uploadResult = "导入文件，部分输入错误";
          //考虑到补导入，就将batchTaskId和appendRows存储两次，不会被清除
          this.importForm.batchNumber = result.meta.resultObject.batchTaskId;
          this.importForm.batchNumTwo = result.meta.resultObject.batchTaskId;
          this.importForm.appendRows = result.meta.resultObject.appendRows;
          this.importForm.appendTwo = result.meta.resultObject.appendRows;
          this.importForm.uploadClear = result.meta.resultMsg;
          this.buttonLoading = false;
          this.isCheckedFileBtn = true;
        } else if (result.meta.resultCode == 2) {
          this.importForm.uploadResult = "错误，请检查文件填写正确性。";
          this.importForm.uploadClear = result.meta.resultMsg;
          //this.$message({message: result.meta.resultMsg, type: "warning", duration: 0, showClose: true,});
          //this.dialogClose();
          this.buttonLoading = false;
          this.isCheckedFileBtn = true;
        } else {
        }
      } else {
        this.buttonLoading = false;
      }
    },
    //移除文件事件
    handleRemove() {
      this.file = {};
      this.importForm.uploadResult = "";
      this.importForm.uploadClear = "";
      this.$refs.upload.clearFiles();
      this.isCheckedFileBtn = true;
      this.importForm.batchNumber = "";
      this.importForm.appendRows = "";
      this.buttonLoading = false;
    },
    //文件选取事件
    changeFile(file) {
      const isLt10M = file.size / 1024 / 1024 < 10; //10MB大小限制
      if (!isLt10M) {
        this.$refs.upload.clearFiles(); //清空选取的文件
        this.$alert("上传文件大小不能超过 10MB！请您重新选取。", "提示", {
          type: "warning",
          confirmButtonText: "关闭",
        });
        return false;
      } else {
        this.file = file.raw;
      }
    },
    //补导入选项事件
    radioClick(e) {
      e === this.importForm.radio
        ? (this.importForm.radio = 0)
        : (this.importForm.radio = e);
    },

    /**
     * 导入归档单
     */
    qryOrderItemList(row) {
      this.isContent.ODKInfo = {};
      this.isContent.width = "95%";
      this.isContent.content = "SearchCondition";
      this.isContent.ODKInfo.custId = this.FormModel.custId;
      this.pendItemVisible = true;
    },

    //导入归档单弹窗关闭后跳转到销售页面
    copyArchiveClose(val) {
      // console.log("val", val);
      this.pendItemVisible = false;
      this.FormModel.custSoNumber = val.custSoNumber;
      this.FormModel.custOrderId = val.custOrderId;
      this.FormModel.custId = "204";
      // console.log("FormModel:", this.FormModel);
      this.qryOrderItem();
    },

    /**
     * 集团客工列表
     */
    async loadMobileNameOptions() {
      let params = {
        interFaceType: "CUST",
        paramStr: "custId:" + this.FormModel.custId,
        sqlId: "2021071904",
      };
      const result = await OrderService.getGroupCustomer(params);
      if (
        result.code == 200 &&
        "meta" in result &&
        "resList" in result.meta &&
        "executeSqlResp" in result.meta.resList
      ) {
        let response = result.meta.resList
          ? result.meta.resList.executeSqlResp
          : [];
        if (response.length >= 1) {
          this.FormModel.mobileName = response[0].cust_work_name;
          this.FormModel.mobilePhone = response[0].mobile_phone;
          this.FormModel.mobileEmail = response[0].e_mail;
        }
      } else {
      }
    },
    /**
     * 集团客工信息回传
     */
    /*getRowMobileNameHandler(row) {
         this.FormModel.mobileName = row.cust_work_name;
         this.FormModel.mobilePhone = row.mobile_phone;
         this.FormModel.mobileEmail = row.e_mail;
    },*/
    /**
     * 获取商机回显合同对应的事件
     * vision:liuxiaofei
     *
     */
    async getContactCdOpt(params) {
      let booleanType = 0;
      if (params.contractcode || params.contractname) {
        booleanType =
          params.contractcode !== "" || params.contractname !== "" ? 1 : 0;
      }
      let obj = {
        requestObject: {
          contractJson: {
            contractcode: "contractcode" in params ? params.contractcode : "",
            contractname: "contractname" in params ? params.contractname : "",
            itemcode: "",
            itemname: "",
            type: booleanType,
            page: {
              pageNo: 1,
              pageSize: 10,
            },
          },
        },
      };
      let loadingInstance = Loading.service({ fullscreen: true });
      let res = await OrderService.qryContractList(obj);
      loadingInstance.close();
      if (res.code == 200) {
        if (res.meta instanceof Array) {
          return res.meta[0];
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .left {
  span {
    padding-left: 0;
    &:before {
      display: none;
    }
  }
}
.tbl-title {
  font-size: $fontSize_v2;
  font-weight: 600;
}
.m-content-box {
  position: relative;
  padding-bottom: 0.6rem;
}
.footBtn {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 10px 0;
  text-align: center;
  z-index: 99;
  background-color: rgba($color: #ccc, $alpha: 0.5);
}
.table-title {
  height: 40px;
  border-bottom: 1px solid #90939947;
  margin-bottom: 8px;
  p {
    height: 40px;
    line-height: 20px;
  }
}
/*弹窗样式*/
.import-container {
  .instructions {
    margin-left: 10px;
  }
  .publicColor {
    color: red;
  }
}
.primaryButton {
  text-align: center;
  margin-top: 10px;
  .el-button--primary {
    width: 100px;
  }
}
.exhibition {
  .is-disabled {
    width: 600px;
  }
    ::v-deep .el-textarea__inner{
        color: #606266;
    }
}
.batchNumber{
    ::v-deep .el-input__inner{
        color: #606266;
    }
}

.upload-demo {
  width: 600px;
  /*margin-top: -10px;*/
  .el-upload__tip {
    height: 15px;
    margin-top: -10px;
    color: red;
  }
}
.el-radio-group {
  margin-left: 10px;
  display: inline;
}
.lineFeed {
  display: block;
  margin-top: -10px;
}
.typeTitle {
  ::v-deep .el-form-item__label {
    margin-top: 6px;
  }
}
.batchNumber {
  width: 300px;
  height: 30px;
}
</style>
